package chpt06;

public class StudentV3 implements Comparable<StudentV3>{
	private String sName;
	private int sAge;
	// 带参数构造方法
	public StudentV3(String sName, int sAge) {
		super();
		this.sName = sName;
		this.sAge = sAge;
	}
	// getter/setter代码
	public String getsName() {
		return sName;
	}
	public void setsName(String sName) {
		this.sName = sName;
	}
	public int getsAge() {
		return sAge;
	}
	public void setsAge(int sAge) {
		this.sAge = sAge;
	}
	// toString方法
	@Override
	public String toString() {
		return "StudentV3 [sName=" + sName + ", sAge=" + sAge + "]";
	}
	@Override
	public int compareTo(StudentV3 o) {
		// 按年龄升序排序
		return this.sAge - o.sAge;
		/* 按年龄降序排序
		return o.sAge - this.sAge; */
		/* 按姓名排序
		return this.sName.compareTo(o.sName); */
	}
}
